/*     */ package com.hp.bon.sgw.bean;
/*     */ 
/*     */ import com.hp.bon.sgw.util.Comutils;
/*     */ import java.util.Date;
/*     */ import org.slf4j.Logger;
/*     */ import org.slf4j.LoggerFactory;
/*     */ 
/*     */ public class SysPertriNetBean
/*     */ {
/*  21 */   private static final Logger logger = LoggerFactory.getLogger(SysPertriNetBean.class);
/*     */   public static final int PETRI_STATUS_ONLINE_ONNET = 0;
/*     */   public static final int PETRI_STATUS_ONLINE_OFFNET = -2;
/*     */   public static final int PETRI_STATUS_ONLINE_ERROR_ONNET = -8;
/*     */   public static final int PETRI_STATUS_ONLINE_ERROR_OFFNET = -9;
/*     */   public static final int PETRI_STATUS_ONLINE_OVER_ONNET = -10;
/*     */   public static final int PETRI_STATUS_ONLINE_OVER_OFFNET = -11;
/*     */   public static final int PETRI_STATUS_MAINTAIN = -3;
/*     */   public static final int PETRI_STATUS_OFFLINE = -1;
/*     */   public static final int PETRI_STATUS_OFFLINE_ERROR = -7;
/*     */   public static final int PETRI_STATUS_PREPARE_MAITAIN = -4;
/*     */   public static final int PETRI_STATUS_PREPARE_OFFLINE = -6;
/*  86 */   private volatile int status = -3;
/*  87 */   private volatile long statusTime = System.currentTimeMillis();
/*     */ 
/*  89 */   private boolean isController = false;
/*     */ 
/*     */   public SysPertriNetBean()
/*     */   {
/*     */   }
/*     */ 
/*     */   public SysPertriNetBean(boolean pIsController)
/*     */   {
/*  28 */     this.isController = pIsController;
/*     */   }
/*     */ 
/*     */   public int getStatus()
/*     */   {
/*  92 */     return this.status;
/*     */   }
/*     */ 
/*     */   public long getStatusTime() {
/*  96 */     return this.statusTime;
/*     */   }
/*     */ 
/*     */   public boolean isController() {
/* 100 */     return this.isController;
/*     */   }
/*     */ 
/*     */   public void setController(boolean isController) {
/* 104 */     this.isController = isController;
/*     */   }
/*     */ 
/*     */   public boolean switchStatus(int newStatus) {
/* 108 */     int curStat = this.status;
/* 109 */     boolean canSwich = false;
/* 110 */     switch (curStat) {
/*     */     case 0:
/* 112 */       canSwich = (newStatus == 0) || (newStatus == -10) || (newStatus == -2) || (newStatus == -8);
/* 113 */       break;
/*     */     case -2:
/* 116 */       canSwich = (newStatus == 0) || (newStatus == -1) || (newStatus == -3) || (newStatus == -11) || 
/* 117 */         (newStatus == -9) || (newStatus == -2);
/* 118 */       break;
/*     */     case -10:
/* 121 */       canSwich = (newStatus == 0) || (newStatus == -2) || (newStatus == -11) || (newStatus == -8);
/* 122 */       break;
/*     */     case -11:
/* 125 */       canSwich = (newStatus == -10) || (newStatus == 0) || (newStatus == -2) || (newStatus == -9) || 
/* 126 */         (newStatus == -1);
/* 127 */       break;
/*     */     case -8:
/* 130 */       canSwich = (newStatus == 0) || (newStatus == -1) || (newStatus == -7) || (newStatus == -9);
/* 131 */       break;
/*     */     case -9:
/* 134 */       canSwich = (newStatus == -2) || (newStatus == -7) || (newStatus == -1);
/* 135 */       break;
/*     */     case -1:
/* 138 */       canSwich = (newStatus == -3) || (newStatus == -2);
/* 139 */       break;
/*     */     case -7:
/* 142 */       canSwich = newStatus == -1;
/* 143 */       break;
/*     */     case -3:
/* 146 */       canSwich = (newStatus == -1) || (newStatus == -2);
/* 147 */       break;
/*     */     case -4:
/* 150 */       canSwich = (newStatus == -1) || (newStatus == -7);
/* 151 */       break;
/*     */     case -6:
/* 154 */       canSwich = (newStatus == -1) || (newStatus == -7);
/*     */     case -5:
/*     */     }
/*     */ 
/* 158 */     return canSwich;
/*     */   }
/*     */ 
/*     */   public void setErrorStatus()
/*     */   {
/* 165 */     switch (this.status) {
/*     */     case 0:
/* 167 */       setNewStatus(-8);
/* 168 */       return;
/*     */     case -2:
/* 170 */       setNewStatus(-9);
/* 171 */       return;
/*     */     case -1:
/*     */     }
/*     */   }
/*     */ 
/*     */   public void setOverLoadStatus()
/*     */   {
/* 179 */     switch (this.status) {
/*     */     case 0:
/* 181 */       setNewStatus(-10);
/* 182 */       return;
/*     */     case -2:
/* 184 */       setNewStatus(-11);
/* 185 */       return;
/*     */     case -1:
/*     */     }
/*     */   }
/*     */ 
/*     */   public void resetOverLoadStatus()
/*     */   {
/* 194 */     switch (this.status) {
/*     */     case -10:
/* 196 */       setNewStatus(0);
/* 197 */       return;
/*     */     case -11:
/* 199 */       setNewStatus(-2);
/* 200 */       return;
/*     */     }
/*     */   }
/*     */ 
/*     */   public void setNewStatus(int newStatus) {
/* 205 */     int oldStatus = this.status;
/* 206 */     this.status = newStatus;
/* 207 */     this.statusTime = System.currentTimeMillis();
/* 208 */     if ((this.isController) && (oldStatus != this.status))
/* 209 */       logger.info("sgwstatuschanged|" + oldStatus + "|" + this.status + "|status changed from " + getPertiStatusName(oldStatus) + " to " + getPertiStatusName(newStatus));
/*     */   }
/*     */ 
/*     */   public static String getPertiStatusName(int status)
/*     */   {
/* 214 */     switch (status) {
/*     */     case 0:
/* 216 */       return "online(active)";
/*     */     case -2:
/* 218 */       return "online(deactive)";
/*     */     case -8:
/* 220 */       return "online error(active)";
/*     */     case -9:
/* 222 */       return "online error(deactive)";
/*     */     case -10:
/* 224 */       return "online over(active)";
/*     */     case -11:
/* 226 */       return "online over(deactive)";
/*     */     case -1:
/* 228 */       return "offline";
/*     */     case -7:
/* 230 */       return "offline error";
/*     */     case -3:
/* 232 */       return "maintain";
/*     */     case -4:
/* 234 */       return "prepair maintain";
/*     */     case -6:
/* 236 */       return "prepair offline";
/*     */     case -5:
/* 238 */     }return "Unkown:" + status;
/*     */   }
/*     */ 
/*     */   public String getPertiStatusName()
/*     */   {
/* 243 */     return getPertiStatusName(this.status);
/*     */   }
/*     */ 
/*     */   public boolean canHandleNewRequest() {
/* 247 */     int curStat = this.status;
/* 248 */     return curStat == 0;
/*     */   }
/*     */ 
/*     */   public String toPrint() {
/* 252 */     return "Petri status :" + getPertiStatusName() + " start at " + new Date(getStatusTime()) + " run time " + Comutils.timeToSpanDay(System.currentTimeMillis() - getStatusTime());
/*     */   }
/*     */ 
/*     */   public static int getChangeCode(int oldStatus, int newStatus)
/*     */   {
/* 263 */     switch (oldStatus) {
/*     */     case 0:
/* 265 */       switch (newStatus) {
/*     */       case -10:
/* 267 */         return 11601;
/*     */       case -2:
/* 269 */         return 11602;
/*     */       case -8:
/* 271 */         return 11603;
/*     */       }
/*     */     case -2:
/* 274 */       switch (newStatus) {
/*     */       case 0:
/* 276 */         return 11604;
/*     */       case -1:
/* 278 */         return 11605;
/*     */       case -3:
/* 280 */         return 11606;
/*     */       case -11:
/* 282 */         return 11607;
/*     */       case -9:
/* 284 */         return 11608;
/*     */       case -10:
/*     */       case -8:
/*     */       case -7:
/*     */       case -6:
/*     */       case -5:
/*     */       case -4:
/*     */       case -2: } case -10:
/* 287 */       switch (newStatus) {
/*     */       case -11:
/* 289 */         return 11609;
/*     */       case 0:
/* 291 */         return 11610;
/*     */       case -8:
/* 293 */         return 11611;
/*     */       }
/*     */     case -11:
/* 296 */       switch (newStatus) {
/*     */       case -10:
/* 298 */         return 11612;
/*     */       case -2:
/* 300 */         return 11613;
/*     */       case -9:
/* 302 */         return 11614;
/*     */       case -1:
/* 304 */         return 11615;
/*     */       case -8:
/*     */       case -7:
/*     */       case -6:
/*     */       case -5:
/*     */       case -4:
/*     */       case -3: } case -8:
/* 307 */       switch (newStatus) {
/*     */       case 0:
/* 309 */         return 11616;
/*     */       case -9:
/* 311 */         return 11617;
/*     */       }
/*     */     case -9:
/* 314 */       switch (newStatus) {
/*     */       case -2:
/* 316 */         return 11618;
/*     */       case -8:
/* 318 */         return 11619;
/*     */       case -7:
/* 320 */         return 11620;
/*     */       case -6:
/*     */       case -5:
/*     */       case -4:
/*     */       case -3: } case -1:
/* 323 */       switch (newStatus) {
/*     */       case -2:
/* 325 */         return 11621;
/*     */       case -3:
/* 327 */         return 11622;
/*     */       }
/*     */     case -7: 
/* 330 */       switch (newStatus) {
/*     */       case -1:
/* 332 */         return 11623;
/*     */       }
/*     */     case -3:
/* 335 */       switch (newStatus) {
/*     */       case -1:
/* 337 */         return 11624;
/*     */       case -2:
/* 339 */         return 11625; } break;
/*     */     case -6:
/*     */     case -5:
/* 342 */     case -4: } return -1;
/*     */   }
/*     */ 
/*     */   public static boolean getIfOnNet(int status)
/*     */   {
/* 353 */     switch (status) {
/*     */     case -10:
/*     */     case -8:
/*     */     case 0:
/* 357 */       return true;
/*     */     }
/* 359 */     return false;
/*     */   }
/*     */ 
/*     */   public boolean getIfOnNet()
/*     */   {
/* 370 */     switch (this.status) {
/*     */     case -10:
/*     */     case -8:
/*     */     case 0:
/* 374 */       return true;
/*     */     }
/* 376 */     return false;
/*     */   }
/*     */ 
/*     */   public static int getSNMPStatusCode(int status)
/*     */   {
/* 388 */     switch (status) {
/*     */     case -2:
/*     */     case 0:
/* 391 */       return 0;
/*     */     case -11:
/*     */     case -10:
/* 394 */       return 1;
/*     */     case -9:
/*     */     case -8:
/* 397 */       return 2;
/*     */     case -3:
/* 399 */       return 3;
/*     */     case -1:
/* 401 */       return 4;
/*     */     case -7:
/* 403 */       return 5;
/*     */     case -6:
/*     */     case -5:
/* 405 */     case -4: } return 6;
/*     */   }
/*     */ 
/*     */   public boolean canAutoMonitorNodesNormal()
/*     */   {
/* 416 */     switch (this.status) {
/*     */     case -11:
/*     */     case -10:
/*     */     case -9:
/*     */     case -8:
/*     */     case -2:
/*     */     case 0:
/* 423 */       return true;
/*     */     case -7:
/*     */     case -6:
/*     */     case -5:
/*     */     case -4:
/*     */     case -3:
/* 425 */     case -1: } return false;
/*     */   }
/*     */ }

/* Location:           C:\Users\think\Desktop\sgw_2.1.jar
 * Qualified Name:     com.hp.bon.sgw.bean.SysPertriNetBean
 * JD-Core Version:    0.6.1
 */